package com.zx.service.impl;/*
 *@program:SSM
 *@author: zhangjian
 *@Time: 2021/7/22  22:52
 */


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zx.DAO.ProjectDao;
import com.zx.entity.Change;
import com.zx.entity.Project;
import com.zx.entity.Role;
import com.zx.service.ProjectService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProjectServiceImpl implements ProjectService {
    private static final int PAGESIZE=3;
    private int pages;

    @Resource
    private ProjectDao projectDao;


    @Override
    public List findMyProject(String user, String state) {
        return projectDao.findMyProject(user,state);
    }

    @Override
    public Object findProjectByID2(String pid) {
        return projectDao.findProjectByID2(pid);
    }

    @Override
    public Object findcontractByPid(String pid) {
        return projectDao.findcontractByPid(pid);
    }

    @Override
    public Object findFundsByPID(String pid) {
        return projectDao.findFundsByPID(pid);
    }

    @Override
    public void checkProject(String pid) {
        projectDao.checkProject(Integer.parseInt(pid));
    }

    @Override
    public List findAllProject2() {
        return projectDao.findAllProject2();
    }

    @Override
    public void toCheck(String pid) {
        projectDao.toCheck(Integer.parseInt(pid));
    }

    @Override
    public List findallproject3(String page) {
        Page<Object> objects = PageHelper.startPage(Integer.parseInt(page), PAGESIZE);
        List list = projectDao.findallproject3();
        pages= objects.getPages();
        return list;
    }

    @Override
    public int getPPages() {
        return pages;
    }

    @Override
    public void changeproject(Change change) {
        projectDao.changeproject(change);
        projectDao.changeprojectstate(change.getPid());
    }

    @Override
    public void updateChange(String pid, String pone, String pmsg, String chpeople) {
        int i = projectDao.approveChange(Integer.parseInt(pid), pone, pmsg);
        System.out.println(i);
        projectDao.updateChpeople(Integer.parseInt(pid),chpeople);
    }

    @Override
    public void deletechange(String pid) {
        projectDao.deletechange(Integer.parseInt(pid));
    }

    @Override
    public List findAllchange() {
        return projectDao.findAllchange();
    }

    //添加申请信息
    @Override
    public void addProject(Project project) {
        projectDao.addProject(project);
    }

    //添加意见栏（受理）
    @Override
    public void updateAdvice(Project project) {
        projectDao.updateAdvice(project);
    }

    //评审意见栏
    @Override
    public void updateAdvice1(Project project) {
        projectDao.updateAdvice1(project);
    }

    //查询受理
    @Override
    public List<Project> findProjectShou() {
        List<Project> list = projectDao.findProjectShou();
        return list;
    }

    //查询评审
    @Override
    public List<Project> findProjectPing() {
        List<Project>list = projectDao.findProjectPing();
        return list;
    }

    //立项意见栏
    @Override
    public void updateAdvice2(Project project) {
        projectDao.updateAdvice2(project);
    }

    //查询立项
    @Override
    public List<Project> findProjectLi() {
        List<Project>list = projectDao.findProjectLi();
        return list;
    }

    //删除申请信息
    @Override
    public void deleteProject(Integer pid) {
        projectDao.deleteProject(pid);
    }

    //修改申请信息
    @Override
    public void updateProject(Project project) {
        projectDao.updateProject(project);
    }

    //查询申请信息
    @Override
    public List<Project> findProjectShen() {
        List<Project> list = projectDao.findProjectShen();
        return list;
    }

    //查询全部
    @Override
    public List<Project> findAll() {
        List<Project> list = projectDao.findAll();
        return list;
    }

    //更新前查询
    @Override
    public Project findProjectByID(int pid) {
        return projectDao.findProjectByID(pid);
    }

    //更新
    @Override
    public void updateProjectByID(Project project) {
        projectDao.updateProjectByID(project);
    }
}
